package com.xiay.stringboot.util;

import com.xiay.stringboot.doman.Result;
import com.xiay.stringboot.enums.ResultEnum;

/**
 * Created by H-209-FX-XY on 2018/5/9.
 */
public class ResultUtil {

    public static Result success(Object object){
        Result result = new Result();
        result.setMsg(ResultEnum.SUCCESS.getMeg());
        result.setCode(ResultEnum.SUCCESS.getCode());
        result.setData(object);
        return result;
    }

    public static Result success(){
       return success(null);
    }


    public static Result error(ResultEnum resultEnum){
        Result result = new Result();
        result.setMsg(resultEnum.getMeg());
        result.setCode(resultEnum.getCode());
        result.setData(null);
        return result;
    }

    public static Result error(Integer code,String msg ){
        Result result = new Result();
        result.setMsg(msg);
        result.setCode(code);
        result.setData(null);
        return result;
    }

}
